<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%-- 引入页面头 --%>
<%@ include file="/pageHead.jsp"%>
<form name="form1" id="form1"
	action="<%-- ${systemctx}/sample/saveSample.web --%>" method="post">
	<div class="pageMain">
		<div class="pageTitle">
			<%=MessageResourcesUtils.getMessage(request,"systemmanage.bascmanagement.title")%>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request,"systemmanage.report.reportlist.list")%>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request,"systemmanage.report.title")%>
		</div>
		<div class="pageBody">
			<div class="form-group">
				<ul>
					<li>
						<i></i> <label><%=MessageResourcesUtils.getMessage(request,"systemmanage.report.reportlist.reportname")%></label>
						<span><input type="text" id="reportname" name="reportname" value="" /></span>
					</li>
				</ul>
			</div>
		</div>
		<div class="button-group">
			<input type="button" class="btn btn-default" id="butQuery" name="butQuery" value="<%=MessageResourcesUtils.getMessage(request,"common.button.query")%>" />
			<input type="button" class="btn btn-default" onclick="reportAdd()" value="<%=MessageResourcesUtils.getMessage(request,"common.button.add")%>" />
			<input type="button" class="btn btn-default" onclick="reportStart()" value="<%=MessageResourcesUtils.getMessage(request,"common.button.start")%>" />
			<input type="button" class="btn btn-default" onclick="reportStop()" value="<%=MessageResourcesUtils.getMessage(request,"common.button.stop")%>" />
		</div>
		<table width="100%">
			<tbody>
				<tr>
					<td>
						<table id="datagrid"></table>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</form>
<script type="text/javascript">
$(document).ready(function() {
	//加载分页控件 datagrid
	$('#datagrid').issdatagrid(
	{
		formid : 'form1',
		title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.report.title")%>',
		width : 'auto',
		nowrap : true,
		autoRowHeight : false,
		singleSelect : false,
		striped : true,
		//collapsible:true,
		url : '${systemctx}/systemmanage/report/queryReportListInfoDataGrid.json',
		sortName : 'usedstatus,modifytime',
		sortOrder : 'desc',
		remoteSort : true,
		idField : 'id',
		pagination : true,
		rownumbers : true,
		showFooter : true,
		queryParams:$('#form1').serializeObject(),
		columns : [ 
		[{field:'ck', checkbox:true}, 
		 {
			field : 'id',
			title : '<%=MessageResourcesUtils.getMessage(request,"common.button.operation")%>',
			width : 70,
			align : 'center',
			formatter : operate
		},{
			title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.report.reportlist.reportname")%>',
			field : 'reportname',
			width : 160,
			sortable : true,
			align : 'left'
		}, {
			title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.report.reportlist.reporturl")%>',
			field : 'reporturl',
			width : 160,
			sortable : true,
			align : 'left'
		}, {
			title : '<%=MessageResourcesUtils.getMessage(request,"systemmanage.report.reportlist.usedstatus")%>',
			field : 'usedstatus',
			width : 80,
			sortable : true,
			align : 'center'
		} ] ],
		onLoadSuccess : function(data) {

		}
	});

	$('#butQuery').click(function() {
		$('#datagrid').datagrid('load',$('#form1').serializeObject());
	});

	function operate(val, row) {
		return '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="reportUpdate('+ 
				val+ ')"><%=MessageResourcesUtils.getMessage(request,"common.button.update")%></a> ';
	}
});
	
function reportAdd() {
	$(this).isswindow({
		noheader : true,
		url : '${systemctx}/systemmanage/report/toAddReport.web'
	});
}
	
function reportUpdate(val) {
	var id = val;
	$(this).isswindow({
		noheader : true,
		url : '${systemctx}/systemmanage/report/toUpdateReport.web?id=' + id
	});
}

function reportStart(){
	var rows = $('#datagrid').datagrid('getSelections');
	if(rows.length == 0){
		alert('<%=MessageResourcesUtils.getMessage(request, "systemmanage.report.reportlist.alert")%>');
		return;
	}else{
		ids = '';
		for(var i=0; i<rows.length; i++){
			ids=ids+rows[i].id+",";
		}
	}
	
	if (ids != '' && ids != undefined) {
		var reportids = ids;
		if(confirm('<%=MessageResourcesUtils.getMessage(request, "systemmanage.report.reportlist.confirm1")%>')){
			// 显示进度条
			showSending();
			$.ajax({
				type : 'GET',
				url : '${systemctx}/systemmanage/report/reportStart.json?reportids='+reportids,
				dataType : 'json',
				success : function(data) {
					//关闭执行...
					closeSending();
					if(data.messagetype == 1){//启用成功
						//显示AJAX请求后的提示信息
						$.fn.ajaxmessage(data);
						$('#datagrid').datagrid('reload',$('#form1').serializeObject());
						$('#datagrid').datagrid('clearSelections');
					}else{//启用失败 
						$.fn.ajaxmessage(data);//打印信息
					}
				}
			});
		}
	}
}

function reportStop(){
	var rows = $('#datagrid').datagrid('getSelections');
	if(rows.length == 0){
		alert('<%=MessageResourcesUtils.getMessage(request, "systemmanage.report.reportlist.alert")%>');
		return;
	}else{
		ids = '';
		for(var i=0; i<rows.length; i++){
			ids=ids+rows[i].id+",";
		}
	}
	
	if (ids != '' && ids != undefined) {
		var reportids = ids;
		if(confirm('<%=MessageResourcesUtils.getMessage(request, "systemmanage.report.reportlist.confirm2")%>')){
			// 显示进度条
			showSending();
			$.ajax({
				type : 'GET',
				url : '${systemctx}/systemmanage/report/reportStop.json?reportids='+reportids,
				dataType : 'json',
				success : function(data) {
					//关闭执行...
					closeSending();
					if(data.messagetype == 1){//启用成功
						//显示AJAX请求后的提示信息
						$.fn.ajaxmessage(data);
						$('#datagrid').datagrid('reload',$('#form1').serializeObject());
						$('#datagrid').datagrid('clearSelections');
					}else{//启用失败 
						$.fn.ajaxmessage(data);//打印信息
					}
				}
			});
		}
	}
}
	
	<%-- function provinceDelete(val) {
		var id = val;
		if (confirm("<%=MessageResourcesUtils.getMessage(request, "alertinfo.common.jsp.alert2") %>")) {
			//正在执行...
			showSending();
			$.ajax({
				type : 'GET',
				url : '${systemctx}/systemmanage/province/deleteProvince.json?id=' + id,
				dataType : 'json',
				success : function(data) {
					//关闭执行...
					closeSending();
					if(data.message == "<%=MessageResourcesUtils.getMessage(request, "alertinfo.common.java.alert3")%>"){
						//显示AJAX请求后的提示信息
						$.fn.ajaxmessage(data);
						$('#datagrid').datagrid('reload',
								$('#form1').serializeObject());
						$('#datagrid').datagrid('clearSelections');
					}else if(data.message == "<%=MessageResourcesUtils.getMessage(request, "systemmanage.province.provinceList.alert1")%>"){
						$.fn.ajaxmessage(data);
					}
				}
			});
		}
	} --%>
</script>
<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>